package zhihuilan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import zhihuilan.dto.MyAcquisitionMsgDto;
import zhihuilan.entity.MyAcquisitionMsgExtra;
import zhihuilan.entity.MyAcquisitionMsg;

import java.util.List;

@Mapper
public interface MyAcquisitionMsgMapper extends BaseMapper<MyAcquisitionMsg> {

    @Select({" <script> select a.*,b.userreal userreal,b.telephone tphone,b.headimgurl user_logo from my_acquisition_msg a " +
            " left join my_staff b on a.staff_id = b.id \n" +
            " where 1=1 " +
            " <when test='status != null and status != \"\"'> " +
            " and a.status &gt; 0 \n" +
            " </when> " +
            " <when test='staffId != null and staffId != \"\"'> " +
            "  and a.staff_id = #{staffId} \n" +
            " </when> " +
            " <when test='pid != null and pid != \"\"'> " +
            "  and a.pid = #{pid} \n" +
            " </when> " +
            " order by create_time desc LIMIT #{page},#{pageSize} " +
            " </script>"})
    List<MyAcquisitionMsgDto> selectMyAcquisitionMsgPage(@Param("page") Long page, @Param("pageSize") Long pageSize, @Param("pid") Integer pid, @Param("staffId") Integer staffId, @Param("status") Integer status);

    @Select({" <script> select count(1) from ( select a.*,b.userreal userreal,b.telephone tphone,b.headimgurl user_logo from my_acquisition_msg a  " +
            " left join my_staff b on a.staff_id = b.id \n" +
            " where 1=1 " +
            " <when test='status != null and status != \"\"'> " +
            " and a.status &gt; 0 \n" +
            " </when> " +
            " <when test='staffId != null and staffId != \"\"'> " +
            "  and a.staff_id = #{staffId} \n" +
            " </when> " +
            " <when test='pid != null and pid != \"\"'> " +
            "  and a.pid = #{pid} \n" +
            " </when> ) tab " +
            " </script>"})
    Integer selectMyAcquisitionMsgCount(@Param("pid") Integer pid, @Param("staffId") Integer staffId, @Param("status") Integer status);
}
